﻿using StructureMap;
using Tarantino.Core;
using Tarantino.Core.Commons.Services.Security;
using Tarantino.Samples.Core.Model;

namespace Tarantino.Samples.Core.Services.Security.Impl
{
	[Pluggable(ServiceKeys.Default)]
	public class SystemUserFactory : ISystemUserFactory
	{
		private readonly IEncryptionEngine _encryptionEngine;

		public SystemUserFactory(IEncryptionEngine encryptionEngine)
		{
			_encryptionEngine = encryptionEngine;
		}

		public SystemUser CreateUser(string emailAddress, string password, string firstName, string lastName)
		{
			SystemUser user = new SystemUser();
			user.EmailAddress = emailAddress;
			user.Password = _encryptionEngine.Encrypt(password);
			user.FirstName = firstName;
			user.LastName = lastName;

			return user;
		}
	}
}